home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / t_os / gpen32k / source.exe / SRC / GPEN32KS.C < prev    next >
C/C++ Source or Header  |  1993-08-04  |  3KB  |  155 lines

  1. /*****************************************************************
  2.  
  3.         G-Pen32k専用部
  4.                             Copyright(C) 1991,1992,1993 Okome
  5. *****************************************************************/
  6.  
  7. #include    <stdio.h>
  8. #include    <stdlib.h>
  9. #include    <string.h>
  10. #include    <EGB.h>
  11. #include    <MOS.h>
  12. #include    <Normlib.h>
  13. #include    <GPen32k.h>
  14. #include    <GPenSub.c>
  15.  
  16. void tcl(int mb, int s)
  17. {
  18.     int i, b, r, g;
  19.     s+=4;
  20.     if (s==4 || s==5)
  21.     {
  22.         mcl[s] = mcl[mb];
  23.     }
  24.     for (i = 0; i<CBX4; i++)
  25.     {
  26.         b = (( mcl[5]     & 0x1f)*i+( mcl[4]     & 0x1f)*(CBX4-i)+CBX4/2)/CBX4;
  27.         r = (((mcl[5]>> 5)& 0x1f)*i+((mcl[4]>> 5)& 0x1f)*(CBX4-i)+CBX4/2)/CBX4;
  28.         g = (((mcl[5]>>10)& 0x1f)*i+((mcl[4]>>10)& 0x1f)*(CBX4-i)+CBX4/2)/CBX4;
  29.         line( CBX1+i,CBY1,CBX1+i,CBY2, (g << 10) + (r << 5) + b );
  30.     }
  31.     boxf( CBLX1,CBLY1,CBLX2,CBLY2, mcl[4] );
  32.     boxf( CBRX1,CBRY1,CBRX2,CBRY2, mcl[5] );
  33. }
  34.  
  35. void wsize( int s )
  36. {
  37.     static int k=3;
  38.     int h = 2;
  39.     wget();
  40.     wpg(0);
  41.     boxf( (NX1-h)*bi-1, (NY1-h)*bi-1, (NX2+h+1)*bi, (NY2+h+1)*bi, BCL );
  42.     wkugiri(0);
  43.     nx[k] = NX1;
  44.     ny[k] = NY1;
  45.     k = (k+1) % (5+s);
  46.     if (k == 0)
  47.         wb = wallb;
  48.     else
  49.     if (k == 5)
  50.         wb = &(b[256*1024-32768]);
  51.     else
  52.         wb+=NX4 * NY4 * 2;
  53.     NX4 = (8/bi) << k;
  54.     NY4 = NX4;
  55.     NX1 = nx[k];
  56.     NY1 = ny[k];
  57.     wkugiri(1);
  58.     wpg(1);
  59.     wput();
  60.     wpg(0);
  61.     biboxbf( NX1, NY1, NX2, NY2, 0, 4, 4 );
  62.     wpg(1);
  63. }
  64.  
  65. /*    カラー選択パレット    */
  66. void mcolms( int j )        /*    カラーバー  □表示    */
  67. {
  68.     int c;
  69.     c = ( mcl[0] / (1 << (j*5))) & 0x1f;
  70.     j = 2 - j;
  71.     boxf( PALX*bi + 1  , PALY*bi + j   *PALB*bi + 1,
  72.           PALX*bi + 255, PALY*bi +(j+1)*PALB*bi - 1, 0 );
  73.     boxb( PALX*bi + c * 8 + 2, PALY*bi + j   *PALB*bi + 2,
  74.           PALX*bi + c * 8 + 7, PALY*bi +(j+1)*PALB*bi - 1, 8 );
  75.     boxb( PALX*bi + c * 8 + 1, PALY*bi + j   *PALB*bi + 1,
  76.           PALX*bi + c * 8 + 6, PALY*bi +(j+1)*PALB*bi - 2, 15 );
  77. }
  78.  
  79. void mcols( int k )
  80. {
  81.     int j;
  82.     if ( k != mcl[0] )
  83.     {
  84.         mcl[0] = k;
  85.         mbclp();
  86.         for ( k = 0; k <= 2; k++ )
  87.         {
  88.             EGB_writeMode( work, 3 );
  89.             boxf(PALX    , PALY+(k+1)*PALB-2,
  90.                  PALX+127, PALY+(k+1)*PALB-1, 0x1f * (1 << ((2 - k) * 5)));
  91.             EGB_writeMode( work, 2 );
  92.             boxf(PALX    , PALY+(k+1)*PALB-2,
  93.                  PALX+127, PALY+(k+1)*PALB-1,
  94.                  mcl[0] & (0x7fff - 0x1f * (1 << ((2 - k) * 5))));
  95.         }
  96.         EGB_writeMode( work, 0 );
  97.         wpg(0);
  98.         for ( j=0; j<=2; j++)
  99.             mcolms(j);
  100.         wpg(1);
  101.     }
  102. }
  103.  
  104. void ptnsave4pg( char *name, int sx, int sy )
  105. {
  106.     int x, y, p;
  107.     FILE *fp;
  108.     if ((fp = fopen( name, "wb")) == NULL )
  109.     {    return;    }
  110.     for (p=0; p<=3; p++ )
  111.     {
  112.         for ( y=0; y<128/sy; y++ )
  113.         {
  114.             for ( x=0; x<128/sx; x++ )
  115.             {
  116.                 egbget(BX1+x*sx,BY1+y*sy,BX1+sx-1+x*sx,BY1+sy-1+y*sy,b);
  117.                 fwrite(b, 1, sx*sy*2, fp);
  118.             }
  119.         }
  120.         page(1);
  121.     }
  122.     page(-4);
  123.     fclose(fp);
  124. }
  125.  
  126. void ptnload4pg( char *name, int sx, int sy )
  127. {
  128.     int x, y, p;
  129.     FILE *fp;
  130.     if ((fp = fopen( name, "rb")) == NULL )
  131.     {    return;    }
  132.     for (p=0; p<=3; p++ )
  133.     {
  134.         for ( y=0; y<128/sy; y++ )
  135.         {
  136.             for ( x=0; x<128/sx; x++ )
  137.             {
  138.                 fread(b, 1, sx*sy*2, fp);
  139.                 egbput(BX1+x*sx,BY1+y*sy,BX1+sx-1+x*sx,BY1+sy-1+y*sy,b);
  140.             }
  141.         }
  142.         page(1);
  143.     }
  144.     page(-4);
  145.     fclose(fp);
  146. }
  147.  
  148. void rchc( void )
  149. {
  150.     int mb, mx, my;
  151.     mcl[0]^=0x8000;
  152.     mbclp();
  153.     mbout( &mb, &mx, &my );
  154. }
  155.